#include "Keyboard.h"

void setup() {
  Keyboard.begin();
  Serial.begin(9600);
}
int key = 0;
void loop() {
  if (Serial.available() == 0)
    return;
  key = Serial.read();
  if (key < 100)
  {
    switch (key )
    {
      case 1: Keyboard.press(KEY_KP_1); break;
      case 2: Keyboard.press(KEY_KP_2); break;
      case 3: Keyboard.press(KEY_KP_3); break;
      case 4: Keyboard.press(KEY_KP_4); break;
      case 5: Keyboard.press(32); break;
      case 6: Keyboard.press(KEY_KP_6); break;
      case 7: Keyboard.press(KEY_KP_7); break;
      case 8: Keyboard.press(KEY_KP_8); break;
      case 9: Keyboard.press(KEY_KP_9); break;
    }
  }
  else
  {
    key = key - 100;
    switch (key )
    {
      case 1: Keyboard.release(KEY_KP_1); break;
      case 2: Keyboard.release(KEY_KP_2); break;
      case 3: Keyboard.release(KEY_KP_3); break;
      case 4: Keyboard.release(KEY_KP_4); break;
      case 5: Keyboard.release(32); break;
      case 6: Keyboard.release(KEY_KP_6); break;
      case 7: Keyboard.release(KEY_KP_7); break;
      case 8: Keyboard.release(KEY_KP_8); break;
      case 9: Keyboard.release(KEY_KP_9); break;
    }
  }
}
